package com.situ.day4;

import org.junit.Test;

import javax.xml.transform.Source;

public class ArrayDemo {
    //运行时异常runtime
    //java.lang.ArrayIndexOutOfBoundsException: 4
    //数组下标越界异常
    @Test
    public void tes1() {
        int[] array = {23, 4, 6, 87};
        for (int i = 0; i <= array.length; i++) {
            System.out.println(array[i]);
        }
    }

    @Test
    public void test2() {
        int[][] array = new int[2][3];
        array[0][0] = 1;
        array[0][1] = 2;
        array[0][2] = 3;
        array[1][0] = 4;
        array[1][1] = 5;
        array[1][2] = 6;
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.println(array[i][j]);
            }
        }
    }
    
}
